<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: pl125 <xskjs888@163.com>
// +----------------------------------------------------------------------

namespace api\wxapp\controller;

use api\wxapp\controller\ApiBaseController;
use think\facade\Request;
class UploadController extends ApiBaseController
{

    public function index()
    {
        $file = Request::file('img');
        if(!$file){
            $this->error('请上传图片!!!');
        }
        $path = './uploads/';
        $info = $file->move($path);
        if($info){
            $img = str_replace('\\','/',$info->getSaveName());
            $this->success('上传成功','/uploads/'.$img);
        }else{
            $this->error($file->getError());
        }
    }
}
